<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
if ( ! function_exists('subword'))
{
    
    function subword($string, $length){
        $res = "";
        $temp = explode(' ', $string);
        foreach($temp as $item){
            if(strlen($res.' '.$item) >= $length){
                $res  .= '...';
                break;
            }else{
                $res .= $item.' ';    
            }
        }
        return $res;
    }

}